package com.dao.impl;

import com.Bean.Room;
import com.Bean.RoomId;
import com.Bean.RoomAndRoomType;
import com.dao.RoomIdDao;
import com.util.JdbcUtil;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;

public class RoomIdDaoimpl implements RoomIdDao {
    @Override
    public int insert(RoomId roomId) throws SQLException {
        return 0;
    }

    @Override
    public List<RoomId> queryData(RoomId roomId) throws IllegalAccessException, SQLException, InstantiationException {
        return null;
    }

    @Override
    public int update(RoomId roomId) throws SQLException {
        return 0;
    }

    @Override
    public int deleteById(Object id) throws SQLException {
        return 0;
    }
    //根据房间类型名，返回该类型所拥有的所有房间list
    public List<RoomId> queryRoomWereTypename(String typename) throws IllegalAccessException, SQLException, InstantiationException {
        String sql="select * from room_id where rtid=(select rtid from room where rname=?)";
        List<RoomId> queryroomidweretypename = JdbcUtil.queryroomidweretypename(sql, new Object[]{typename});
        return queryroomidweretypename;
    }
    //返回所有的房间类型
    public List<Room> queryRoomType() throws IllegalAccessException, SQLException, InstantiationException {
        String sql="select * from room";
        List<Room> queryroomtype = JdbcUtil.queryroomtype(sql);
        return queryroomtype;
    }
    //返回所有的房间and类型
    public List<RoomAndRoomType> queryRoomandType() throws IllegalAccessException, SQLException, InstantiationException {
        String sql="select room_id.rtid,room_id.rid,room_id.rstatus,room_id.timetype," +
                "room.rname,room.wkprice,room.weprice,room.rnumber from room_id,room " +
                "where room_id.rtid=room.rtid  ORDER BY room_id.rtid,room_id.rid";
        List<RoomAndRoomType> queryroomidandtype = JdbcUtil.queryroomidandtype(sql);
        return queryroomidandtype;
    }

}
